home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / eiffel / smalleif.97 / se.t / SmallEiffel / lib_std / boolean_ref.e < prev    next >
Encoding:
Text File  |  1996-05-02  |  2.1 KB  |  108 lines

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. class BOOLEAN_REF
  5.    
  6. inherit 
  7.    ANY 
  8.       redefine fill_tagged_out_memory
  9.       end;
  10.    
  11. creation {ANY}
  12.     make
  13.  
  14. feature {ANY}
  15.  
  16.    item: BOOLEAN;      
  17.      -- Value of Current
  18.  
  19.    make(value: BOOLEAN) is
  20.      -- Initialize object
  21.       do  
  22.      item := value
  23.       end;
  24.  
  25.    infix "and" (other : BOOLEAN_REF) : BOOLEAN_REF is
  26.      -- `and' of Current with `other'.
  27.       require
  28.      other /= Void
  29.       do
  30.      !!Result.make (item and other.item)
  31.       end;
  32.  
  33.    infix "and then" (other : BOOLEAN_REF) : BOOLEAN_REF is
  34.      -- Semi-strict `and' of Current with `other'.
  35.       require
  36.      other /= Void
  37.       do
  38.      !!Result.make (item and then other.item)
  39.       end;
  40.  
  41.    infix "implies" (other : BOOLEAN_REF) : BOOLEAN_REF is
  42.      -- Does Current imply `other'.
  43.       require
  44.      other /= Void
  45.       do
  46.      !!Result.make (item implies other.item)
  47.       end;
  48.  
  49.    infix "or" (other : BOOLEAN_REF) : BOOLEAN_REF is
  50.      -- `or' of Current with `other'
  51.       require
  52.      other_not_void : other /= Void
  53.       do
  54.      !!Result.make (item or other.item)
  55.       end;
  56.  
  57.    infix "or else" (other : BOOLEAN_REF) : BOOLEAN_REF is
  58.      -- Semi-strict `or' of Current with `other'
  59.       require
  60.      other_not_void : other /= Void
  61.       do
  62.      !!Result.make (item or else other.item)
  63.       end;
  64.  
  65.    infix "xor" (other: BOOLEAN_REF): BOOLEAN_REF is
  66.      -- `xor' of Current with `other'
  67.       require
  68.      other /= Void
  69.       do
  70.      !!Result.make (item xor other.item)
  71.       end;
  72.  
  73.    prefix "not": BOOLEAN_REF is
  74.      -- `not' of Current.
  75.       do
  76.      !!Result.make(not item)
  77.       end;
  78.  
  79.    fill_tagged_out_memory is
  80.       do
  81.      tagged_out_memory.append("item: ");
  82.      if item then
  83.         tagged_out_memory.append("true");
  84.      else     
  85.         tagged_out_memory.append("false");
  86.      end;
  87.       end;
  88.  
  89.    to_string: STRING is
  90.       do
  91.      if Current.item then
  92.         Result := "true";
  93.      else
  94.         Result := "false";
  95.      end;
  96.       end;
  97.    
  98.    to_integer: INTEGER is
  99.       do
  100.      if Current.item then
  101.         Result := 1;
  102.      else
  103.         Result := 0;
  104.      end;
  105.       end;
  106.    
  107. end -- BOOLEAN_REF
  108.